Repository navigation
feat: show a poll's options and give a poll option its own page - #348
Merged
Merged
Conversation
therealsama
force-pushed
the
feat/poll-options
branch
3 times, most recently
from
November 25, 2026 09:25
f8d2d1b to
0c9cd74
Compare
A poll now lists its options in HN's order, each with its points, its share of all votes and a bar filled to that share. The leading option is bold. A poll of more than 12 options shows its top 10 until asked, and collapsing keeps the toggle where it was on screen. HN's order is by points, most first, with ties in `parts` order. The API docs call `parts` display order, but HN's pages sort by points; this held for 27 of 28 polls checked, scale polls included. The options are sorted (stably) where they're read, so cached and merged copies keep that order. Options are read from the poll's `parts` while its comments are put in HN's order. They're read all at once, not in batches: reads share one WebSocket, so batches would only add round trips. They're read all-or-nothing, since a missing option would misstate the others' shares. If they can't be read, the poll shows without them and its comments still load; a cached copy without options reads them again the next time it's opened. If the comments can't be read, the poll still shows its options: the failure is a CommentsError that carries the item as read, and the hook shows it on every path that can fail (first load, reconnect, refresh and retry). It isn't cached until its comments load. A poll option opens on its own page, as on HN: its points, author, a link to its poll and share, then its text, laid out like a comment, with its paragraphs and code blocks. On the phone it opens as that page rather than in the swipe viewer, like a job. Its text is also its tab title and share text, where htmlToText puts a space between paragraphs. Polls are tagged `poll`, not `story`, on Algolia, so a user's submissions and the Top feed's earlier days now ask for `(story,poll)`.
therealsama
force-pushed
the
feat/poll-options
branch
from
November 25, 2026 10:49
64829a0 to
1cfb1b3
Compare
therealsama
enabled auto-merge
November 25, 2026 16:17
kplachkov
approved these changes
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HackerTok showed a poll as a plain text post, and a poll option's page only said it wasn't supported (#341). Both now work as on HN.
What changed
partsorder. HN's API docs saypartsis the display order, but HN's pages sort by points (27 of 28 polls checked).poll, so those queries ask for(story,poll).Not included
Testing
npm run typecheck: passednpm run lint: passednpx vitest run: passed, 1216 testsnpx playwright test --reporter=line --retries=0: passed, 920 passed and 44 skipped across chromium, firefox, Mobile Safari and Mobile Chrome